/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FOUNDATION_ACE_ADAPTER_OHOS_KEELS_ENTRANCE_WINDOW_VIEW_API_H
#define FOUNDATION_ACE_ADAPTER_OHOS_KEELS_ENTRANCE_WINDOW_VIEW_API_H

#include <ace/xcomponent/native_interface_xcomponent.h>
#include <arkui/native_node.h>

namespace Keels::Ace::Platform {
namespace Rosen {
class Window;
} // namespace Rosen

class WindowView {
public:
    WindowView();
    ~WindowView();
    /**
     * @brief 获取XComponent节点，用于挂载到ContentSlot上
     */
    ArkUI_NodeHandle GetNodeHandle() const;
    /**
     * @brief 销毁XComponent节点，触发NativeWindow的销毁
     */
    void DisposeNodeHandle();
    /**
     * @brief Native侧是否准备完毕
     */
    bool IsReady() const;
    /**
     * @brief Native侧是否销毁完毕
     */
    bool IsDestroyed() const;
    /**
     * @brief 更新尺寸和位置
     */
    void UpdateLayout(float width, float height, float left, float top);
    /**
     * @brief 挂载第三方前端（TN TML）子树
     * @param uiRoot 第三方前端子树的根节点
     */
    void MountThirdPartyUIRoot(const void* uiRoot);
    /**
     * @brief 卸载第三方前端（TN TML）子树
     */
    void UnmountThirdPartyUIRoot();

private:
    bool isReady_ = false;
    bool isDestroyed_ = false;
    ArkUI_NodeHandle xComponent_ = nullptr;
    OH_NativeXComponent* component_ = nullptr;
    std::weak_ptr<Rosen::Window> rsWindow_ {};
};
} // namespace Keels::Ace::Platform

#endif // FOUNDATION_ACE_ADAPTER_OHOS_KEELS_ENTRANCE_WINDOW_VIEW_API_H